<?php 
if(!defined('HOST'))die('not access');
?>
<script >
$(document).ready(function(){

	var a = $('#viewworc_{rand}').bootstable({
		celleditor:true,url:'?d=main&m=fenqu&a=data',fanye:false,
		tablename:'2',cellurl:'?m=index&a=savecell',
		method:'get',
		columns:[
			{
				text:"名称",dataIndex:"name",sortable:true,editor:true,align:'left',editormsg:'请规范输入'
			},
			{text:"限制上传类型",dataIndex:"uptype",editor:true,editormsg:'多个,分开',editorattr:'placeholder="为空不限制"'},	
			{text:"可查看人员",dataIndex:"recename"},{text:"管理人员",dataIndex:"guanname"},
			{text:"可上传人员",dataIndex:"upuser"},
			{text:"可下载人员",dataIndex:"downname"},
			{text:"空间大小(字节)",dataIndex:"size",editormsg:'0不限制',sortable:true,editor:admintype==1,editorattr:'placeholder="0不限制"',type:'number'},
			{
				text:"空间大小",dataIndex:"sizee",renderer:function(v,d){
					var str='无限制';
					if(d.size>0)str=js.formatsize(d.size);
					return str;
				}
			},
			{
				text:"已使用大小",dataIndex:"sizeu",align:'left',sortable:true,renderer:function(v,d){
					var str='&nbsp;';
					if(v>0)str=js.formatsize(v);
					if(d.size>0){
						var dx=js.float(100*v/(d.size));
						if(dx>100)dx=100;
						str+='('+dx+'%)';
					}
					return str;
				}
			},
			{
				text:"文件数",dataIndex:"fileshu",sortable:true
			},
			{text:"排序号",dataIndex:"sort",sortable:true,type:'number',editor:true,editormsg:'越大越靠后'},
			
			{text:"创建人",dataIndex:"optname",sortable:true},
			{
				text:'',dataIndex:'caozuos',renderer:function(v,d,oi){
					return '<a class="zhu" onclick="caozuo{rand}('+oi+',this)" style="TEXT-DECORATION:none">操作<i class="icon-angle-down"></i></a>';
				}
			}
		],
		load:function(d){
			
		},
		itemclick:function(){
			get('del{rand}').disabled=false;
		},
		beforeload:function(){
			get('del{rand}').disabled=true;
		}
	});
	
	var menuobj=false;
	caozuo{rand}=function(oi,o1){
		var d = a.getData(oi);
		if(!menuobj)menuobj=$.rockmenu({
			data:[],
			itemsclick:function(d){c.showmenuclick(d);},
			width:150
		});
		var da = [{name:'修改可查看人员',lx:0,id:d.id},{name:'修改管理人员',lx:1,id:d.id},{name:'修改可上传人员',lx:2,id:d.id},{name:'修改可下载人员',lx:3,id:d.id}];
		var off=$(o1).offset();
		menuobj.setData(da);
		setTimeout(function(){menuobj.showAt(off.left,off.top+20)},10);
	}
	
	var c = {
		init:function(){
			
		},
		clickwin:function(){
			js.prompt('输入分区名称',function(jg,txt){
				if(jg=='yes' && txt){
					js.loading('创建中...');
					js.ajax({
						url:js.apiurl('word','createworc'),
						data:{name:txt},
						type:'post',
						success:function(){
							js.msgok('创建成功');
							a.reload();
						}
					});
				}
			},'创建分区');
		},
		relad:function(){
			a.reload();
		},
		showmenuclick:function(d){
			js.changeuser('', 'deptusercheck', d.name,{
				onselect:function(sna,sid){
					if(!sid)return;
					js.loading('修改中...');
					js.ajax({
						url:js.apiurl('word','editworc'),
						data:{sna:sna,sid:sid,id:d.id,lx:d.lx},
						type:'post',
						success:function(){
							js.msgok('修改成功');
							a.reload();
						}
					});
				}
			});
		},
		del:function(){
			a.del({
				msg:'确定要删除选中分区吗，删除分区下文件一起删除。',
				url:js.apiurl('word','delworc')
			});
		},
		reloadhx:function(){
			js.loading('刷新中...');
			js.ajax({
				url:js.apiurl('word','reloadworc'),
				success:function(){
					js.msgok('刷新成功');
					a.reload();
				}
			});
		}
	}
	
	c.init();
	js.initbtn(c);
});

</script>

<div id="buttonlist{rand}">
	<table width="100%">
	<tr>
		<td style="padding-right:10px;" id="tdleft_{rand}" nowrap>
			<button id="addbtn_{rand}" class="webbtn" clickevt="clickwin,0" type="button"><i class="icon-plus"></i> 新增分区</button>&nbsp; 
			<button class="webbtn webbtn-white" clickevt="relad" type="button">刷新</button>
		</td>

		<td align="right" id="tdright_{rand}" nowrap>
			<button class="webbtn webbtn-white" clickevt="reloadhx" type="button">刷新空间大小</button>&nbsp;&nbsp;
			<button class="webbtn webbtn-red" disabled id="del{rand}" clickevt="del" type="button"><i class="icon-trash"></i> 删除</button>
		</td>
	</tr>
	</table>
</div>
<div class="blank10"></div>
<div id="viewworc_{rand}"></div>